home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1 / Nebula One.iso / Graphics / Plotting / aa_Intel_Only / Gnuplot / GnuplotSource / ContourOptionsPanel.m < prev    next >
Encoding:
Text File  |  1995-06-12  |  5.2 KB  |  266 lines

  1. /*
  2.  *  Copyright (C) 1993  Robert Davis
  3.  *
  4.  *  This program is free software; you can redistribute it and/or
  5.  *  modify it under the terms of Version 2, or any later version, of 
  6.  *  the GNU General Public License as published by the Free Software 
  7.  *  Foundation.
  8.  */
  9.  
  10. static char RCSId[]="$Id: ContourOptionsPanel.m,v 1.9 1993/05/18 03:54:47 davis Exp $";
  11.  
  12.  
  13. #import <appkit/Application.h>
  14. #import <appkit/Box.h>
  15. #import <appkit/Button.h>
  16. #import <appkit/Form.h>
  17. #import <appkit/FormCell.h>
  18. #import <appkit/Matrix.h>
  19. #import <appkit/MenuCell.h>
  20. #import <appkit/PopUpList.h>
  21.  
  22. #import "ContourAutoPane.h"
  23. #import "ContourOptionsPanel.h"
  24. #import "ContourSeriesPane.h"
  25. #import "ContourUserPane.h"
  26. #import "Status.h"
  27. #import "StatusContour.h"
  28.  
  29.  
  30. @interface ContourOptionsPanel (Private)
  31. - _setupPane:(Pane *)aPane;
  32. - _selectPane:(int)aPane;
  33. - _swapPane:(Pane *)new;
  34. - _updatePanel;            /** Overridden from OptionsPanel (Private) **/
  35. @end
  36.  
  37.  
  38.  
  39. @implementation ContourOptionsPanel
  40.  
  41. - init
  42. {
  43.     [super init];
  44.  
  45.     [NXApp loadNibSection: "ContourOptionsPanel.nib"
  46.             owner: self
  47.         withNames: NO
  48.          fromZone: [self zone]];
  49.  
  50.     [panel setFrameUsingName:"ContourOptionsPanel"];
  51.     [panel setFrameAutosaveName:"ContourOptionsPanel"];
  52.  
  53.     enabled = NO;
  54.  
  55.     return self;
  56. }
  57.  
  58.  
  59. - free
  60. {
  61.     [seriesPane free];
  62.     [userPane free];
  63.     [autoPane free];
  64.     [[levelsKindButton target] free];
  65.  
  66.     return [super free];
  67. }
  68.  
  69.  
  70. - (BOOL)isEnabled
  71. {
  72.     return enabled;
  73. }
  74.  
  75.  
  76. - doSetKind:sender
  77. {
  78.     [status setContourKind:[sender selectedTag]];
  79.     [self _updatePanel];    /* Changing kind may change other controls */
  80.     return self;
  81. }
  82.  
  83.  
  84. - doSetPoints:sender
  85. {
  86.     [status setContourPoints:[sender intValue]];
  87.  
  88.     /* status may not accept points value */
  89.     [pointsField setIntValue:[status contourPoints]];
  90.  
  91.     return self;
  92. }
  93.  
  94.  
  95. - doSetOrder:sender
  96. {
  97.     [status setContourOrder:[sender intValue]];
  98.  
  99.     /* status may not accept order value */
  100.     [orderField setIntValue:[status contourOrder]];
  101.  
  102.     return self;
  103. }
  104.  
  105.  
  106.  
  107. - doSetKey:sender
  108. {
  109.     return [status setContourInKey:[sender state]];
  110. }
  111.  
  112.  
  113. - doSetLevelsKind:sender
  114. {
  115.     [status setContourLevelsKind:[sender selectedTag]];
  116.     [levelsKindButton setTag:[sender selectedTag]];
  117.     [self _updatePanel];    /* Changing this changes current pane */
  118.     return self;
  119. }
  120.  
  121.  
  122.  
  123. // Shuts up the compiler about unused RCSId
  124. - (const char *) rcsid
  125. {
  126.     return RCSId;
  127. }
  128.  
  129.  
  130.  
  131. @end
  132.  
  133.  
  134.  
  135.  
  136.  
  137. @implementation ContourOptionsPanel (Private)
  138.  
  139. - _setupPane:(Pane *)aPane
  140. {
  141.     if (aPane) {
  142.         View    *panesView = [aPane view];
  143.  
  144.         [[panel contentView] addSubview: panesView];
  145.         [[panesView allocateGState] lockFocus];
  146.         [panesView unlockFocus];
  147.         [panesView moveTo:0:0];
  148.     }
  149.  
  150.     return self;
  151. }
  152.  
  153.  
  154. - _selectPane:(int)aPane
  155. {
  156.     switch (aPane) {
  157.  
  158.     case LEVELS_INCREMENTAL:
  159.         if (!seriesPane) {
  160.             seriesPane = [[ContourSeriesPane allocFromZone:[self zone]] init];
  161.             [self _setupPane:seriesPane];
  162.         }
  163.         [self _swapPane:seriesPane];
  164.         break;
  165.  
  166.     case LEVELS_DISCRETE:
  167.         if (!userPane) {
  168.             userPane = [[ContourUserPane allocFromZone:[self zone]] init];
  169.             [self _setupPane:userPane];
  170.         }
  171.         [self _swapPane:userPane];
  172.         break;
  173.  
  174.     default:
  175.         if (!autoPane) {
  176.             autoPane = [[ContourAutoPane allocFromZone:[self zone]] init];
  177.             [self _setupPane:autoPane];
  178.         }
  179.         [self _swapPane:autoPane];
  180.         break;
  181.  
  182.     }
  183.  
  184.     [currentPane perform:@selector(selectControl:)
  185.             with:self
  186.           afterDelay:1
  187.       cancelPrevious:YES];
  188.  
  189.     return self;
  190. }
  191.  
  192.  
  193.  
  194. - _swapPane:(Pane *)new
  195. {
  196.     /*
  197.      *  If the new pane is not already visible, move it into the panel.
  198.      */
  199.  
  200.     if (new != currentPane) {
  201.  
  202.         [levelsKindBox setContentView: [new view]];
  203.         [currentPane didSwapOut:self];
  204.  
  205.         [[new didSwapIn:self] updateStatus:status doc:self];
  206.         currentPane = new;
  207.  
  208.     }
  209.  
  210.     return self;
  211. }
  212.  
  213.  
  214.  
  215.  
  216. - _updatePanel
  217. {
  218.     int        contourKind = [status contourKind];
  219.     int        levelsKind = [status contourLevelsKind];
  220.  
  221.     [panel disableDisplay];
  222.  
  223.     /* 
  224.      *  If the current status is not nil, update the values of all the 
  225.      *  controls.
  226.      */
  227.     if (status) {
  228.  
  229.     MenuCell    *cell;
  230.  
  231.     [kindMatrix selectCellWithTag:contourKind];
  232.     [pointsField setIntValue:[status contourPoints]];
  233.     [orderField setIntValue:[status contourOrder]];
  234.     [keyButton setState:[status contourInKey]];
  235.  
  236.     cell = [[levelsKindButton target] findCellWithTag:levelsKind];
  237.     [levelsKindButton setTitle:[cell title]];
  238.     [levelsKindButton setTag:levelsKind];
  239.  
  240.     }
  241.  
  242.     enabled = status && [status isThreeD] && 
  243.     ([status contourBase] ||    // contours don't show on opaque surf.
  244.      ([status contourSurface] && ![status hiddenThreeD]));
  245.  
  246.     [kindMatrix setEnabled:enabled];
  247.     [pointsField setEnabled:enabled && (contourKind != CONTOUR_KIND_LINEAR)];
  248.     [orderField setEnabled:enabled && (contourKind == CONTOUR_KIND_BSPLINE)];
  249.     [keyButton setEnabled:enabled];
  250.     [levelsKindButton setEnabled:enabled];
  251.     [levelsKindField setEnabled:enabled];
  252.  
  253.     /*  setEnabled the title in the box around the matrix, too  */
  254.     [[[[kindMatrix superview] superview] cell] setEnabled:enabled];
  255.  
  256.     [self _selectPane:levelsKind];
  257.     [currentPane updateStatus:status doc:self];
  258.  
  259.     [panel reenableDisplay];
  260.     [panel display];
  261.  
  262.     return self;
  263. }
  264.  
  265. @end
  266.